package com.hzhr.iot.collect.constant;

import com.hzhr.iot.core.constant.HttpExceptionCategory;
import com.hzhr.iot.core.constant.ServiceErrors;
import com.hzhr.iot.core.constant.ServiceExceptionCategory;
import org.springframework.http.HttpStatus;
import org.springframework.util.StringUtils;

public enum Collect_ErrorsEnum implements ServiceErrors {
    //region test
    TEST(0, "", "", ServiceExceptionCategory.BUSINESS_EXCEPTION, HttpExceptionCategory.CLIENT_EXCEPTION, HttpStatus.FORBIDDEN);
    //endregion

    private Integer code;
    private String messaeg;
    private String business;
    private ServiceExceptionCategory serviceExceptionCategory;
    private HttpExceptionCategory httpExceptionCategory;
    private HttpStatus httpStatus;
    Collect_ErrorsEnum(Integer code, String business, String message, ServiceExceptionCategory serviceExceptionCategory, HttpExceptionCategory httpExceptionCategory, HttpStatus httpStatus) {
        this.code = code;
        this.business = business;
        this.messaeg = message;
        this.serviceExceptionCategory = serviceExceptionCategory;
        this.httpExceptionCategory = httpExceptionCategory;
        this.httpStatus = httpStatus;
    }
    @Override
    public Integer getCode() {
        return code;
    }
    @Override
    public String getBusiness() {
        return business;
    }
    @Override
    public String getMessage() {
        return messaeg;
    }
    @Override
    public ServiceExceptionCategory getServiceExceptionCategory() {
        return serviceExceptionCategory;
    }
    @Override
    public HttpExceptionCategory getHttpExceptionCategory() {
        return httpExceptionCategory;
    }
    @Override
    public HttpStatus getHttpStatus() {
        return httpStatus;
    }
    @Override
    public void setMessage(String message) {
        this.messaeg = message;
    }

    public static Collect_ErrorsEnum getEnumByName(String name) {
        if (StringUtils.isEmpty(name)) return null;
        for (Collect_ErrorsEnum errorsEnum : Collect_ErrorsEnum.values()) {
            if (errorsEnum.name().equals(name)) {
                return errorsEnum;
            }
        }
        return null;
    }
}
